home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Utilities / PalmLink / src / PL_CMP.c < prev    next >
C/C++ Source or Header  |  2000-05-05  |  4KB  |  146 lines

  1. /**
  2.  * PalmLink -- Connect 3Com Palm with Amiga
  3.  *
  4.  * CMP (Connection Management Protocol)
  5.  *
  6.  * (C) 1998-2000 Richard Körber <rkoerber@gmx.de>
  7.  *
  8.  *------------------------------------------------------------------
  9.  *
  10.  * This program is free software; you can redistribute it and/or modify
  11.  * it under the terms of the GNU General Public License as published by
  12.  * the Free Software Foundation; either version 2 of the License, or
  13.  * any later version.
  14.  *
  15.  * This program is distributed in the hope that it will be useful,
  16.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  18.  * GNU General Public License for more details.
  19.  *
  20.  * You should have received a copy of the GNU General Public License
  21.  * along with this program; if not, write to the Free Software
  22.  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  23.  *
  24.  * You must not use this source code to gain profit of any kind!
  25.  */
  26.  
  27. #include "palmlink_glob.h"
  28.  
  29. /*------------------------------------------------------**
  30. ** Name:        PL_CMPAbort                       public
  31. **
  32. ** Funktion:    CMP: Verbindung abbrechen
  33. **
  34. ** Parameter:   socket    Socket für die Übertragung
  35. **              reason    Grund-Code
  36. ** Ergebnis:    success   Erfolg (boolean)
  37. //>
  38. ** Bemerkungen:
  39. **
  40. ** Revision:     7. Juni 1998, 22:49:33
  41. */
  42. __saveds __asm int PL_CMPAbort
  43. (
  44.   register __a0 APTR socket,
  45.   register __d0 UBYTE reason
  46. )
  47. {
  48.   struct PL_Socket *sock = (struct PL_Socket *)socket;
  49.   struct PL_CMP cmp = { PLCMP_WAKEUP,0,0,0,0 };
  50.  
  51.   sock->lastError = PLERR_OKAY;
  52.   cmp.flags = reason;
  53.   return(-1!=PL_PADPWrite(socket,&cmp,sizeof(struct PL_CMP),PLPADP_DATA));
  54. }
  55. //<
  56.  
  57. /*------------------------------------------------------**
  58. ** Name:        PL_CMPInit                        public
  59. **
  60. ** Funktion:    CMP: Verbindung herstellen
  61. **
  62. ** Parameter:   socket    Socket für die Übertragung
  63. **              baud      Baudrate
  64. ** Ergebnis:    success   Erfolg (boolean)
  65. //>
  66. ** Bemerkungen: Die serielle Schnittstelle wird nicht
  67. **              auf die neue Baudrate gesetzt.
  68. **
  69. ** Revision:     7. Juni 1998, 22:49:33
  70. */
  71. __saveds __asm int PL_CMPInit
  72. (
  73.   register __a0 APTR socket,
  74.   register __d0 ULONG rate
  75. )
  76. {
  77.   struct PL_Socket *sock = (struct PL_Socket *)socket;
  78.   struct PL_CMP cmp = { PLCMP_INIT,0,0,0,0 };
  79.  
  80.   sock->lastError = PLERR_OKAY;
  81.   cmp.baudrate = rate;
  82.   if(rate!=9600) cmp.flags = PLCMPF_CHANGEBAUD;
  83.  
  84.   return(-1!=PL_PADPWrite(socket,&cmp,sizeof(struct PL_CMP),PLPADP_DATA));
  85. }
  86. //<
  87.  
  88. /*------------------------------------------------------**
  89. ** Name:        PL_CMPWakeUp                      public
  90. **
  91. ** Funktion:    CMP: Aufwecken
  92. **
  93. ** Parameter:   socket    Socket für die Übertragung
  94. **              maxbaud   Maximale Baudrate
  95. ** Ergebnis:    success   Erfolg (boolean)
  96. //>
  97. ** Bemerkungen: Die serielle Schnittstelle wird nicht
  98. **              auf die neue Baudrate gesetzt.
  99. **
  100. ** Revision:     7. Juni 1998, 23:00:59
  101. */
  102. __saveds __asm int PL_CMPWakeUp
  103. (
  104.   register __a0 APTR socket,
  105.   register __d0 ULONG maxrate
  106. )
  107. {
  108.   struct PL_Socket *sock = (struct PL_Socket *)socket;
  109.   struct PL_CMP cmp = { PLCMP_WAKEUP,0,PLCMPVER_1_0,0,0 };
  110.  
  111.   sock->lastError = PLERR_OKAY;
  112.   cmp.baudrate = maxrate;
  113.  
  114.   return(-1!=PL_PADPWrite(socket,&cmp,sizeof(struct PL_CMP),PLPADP_WAKE));
  115. }
  116. //<
  117.  
  118. /*------------------------------------------------------**
  119. ** Name:        PL_CMPRead                        public
  120. **
  121. ** Funktion:    CMP: lesen
  122. **
  123. ** Parameter:   socket    Socket für die Übertragung
  124. **              cmp       CMP-Struktur-Puffer
  125. ** Ergebnis:    success   Erfolg (boolean)
  126. //>
  127. ** Bemerkungen:
  128. **
  129. ** Revision:     7. Juni 1998, 23:04:21
  130. */
  131. __saveds __asm int PL_CMPRead
  132. (
  133.   register __a0 APTR socket,
  134.   register __d0 struct PL_CMP *cmp
  135. )
  136. {
  137.   struct PL_Socket *sock = (struct PL_Socket *)socket;
  138.  
  139.   sock->lastError = PLERR_OKAY;
  140.   return(-1!=PL_PADPRead(socket,cmp,sizeof(struct PL_CMP)));
  141. }
  142. //<
  143.  
  144.  
  145. /********************************************************************/
  146.